package com.creative.accountsdk.net.account;

import com.creative.accountsdk.UmsChannel;
import com.creative.accountsdk.UserData;
import com.creative.accountsdk.net.Protocol;
import com.creative.accountsdk.net.XParams;
import com.creative.util.EncodeUtil;
import com.loopj.android.http.RequestParams;

import org.json.JSONObject;

/**
 * Created by wang_qian on 2015/11/25.
 */
public class UserInfoProtocol extends Protocol {

    private int     mGender;
    private String  mBirthDay;
    private String  mCountryCode;
    private String  mNickName;
    private String  mAvartar;
    //private UserData  userData;
    public JSONObject jsonUser;
    private long     Uid;
    private String   Token;

    public UserInfoProtocol(int gender, String birthday, String countrycode, String nickname, String avatar, Long uid, String token) {
        mGender = gender;
        mBirthDay = birthday;
        mCountryCode = countrycode;
        mNickName = nickname;
        mAvartar = avatar;
        //userData = UserData.getInstance();
        Uid = uid;
        Token = token;
    }


    @Override
    public RequestParams getParams() {
        return new XParams().put("gender", mGender)
                .put("avatar", mAvartar)
                .put("birthday", mBirthDay)
                .put("area", mCountryCode)
                .put(UmsChannel.PARAM_NAME, UmsChannel.getChannel())
                .put("token", Token)
                .put("nickname", mNickName).getParams();
    }

    @Override
    public String getUrl() {

        return getUrlPrefix()+"ui/"+Uid;
    }

    @Override
    protected void parseReturnMap(JSONObject returnMap) {
        if (returnMap.has("uinfo")) {
            jsonUser = returnMap.optJSONObject("uinfo");
        }

    }
}
